package com.hytc.mymall.utils;

import android.util.Log;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

public class XMLDOMParser
{
  private final String getTextNodeValue(Node paramNode)
  {
    if ((paramNode != null) && (paramNode.hasChildNodes())) {}
    for (Node localNode = paramNode.getFirstChild();; localNode = localNode.getNextSibling())
    {
      if (localNode == null) {
        return "";
      }
      if (localNode.getNodeType() == 3) {
        return localNode.getNodeValue();
      }
    }
  }
  
  public Document getDocument(InputStream paramInputStream)
  {
    DocumentBuilderFactory localDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
    try
    {
      DocumentBuilder localDocumentBuilder = localDocumentBuilderFactory.newDocumentBuilder();
      InputSource localInputSource = new InputSource(paramInputStream);
      localInputSource.setEncoding("UTF-8");
      Document localDocument = localDocumentBuilder.parse(localInputSource);
      return localDocument;
    }
    catch (ParserConfigurationException localParserConfigurationException)
    {
      Log.e("Error: ", localParserConfigurationException.getMessage());
      return null;
    }
    catch (SAXException localSAXException)
    {
      Log.e("Error: ", localSAXException.getMessage());
      return null;
    }
    catch (IOException localIOException)
    {
      Log.e("Error: ", localIOException.getMessage());
    }
    return null;
  }
  
  public String getValue(Element paramElement, String paramString)
  {
    return getTextNodeValue(paramElement.getElementsByTagName(paramString).item(0));
  }
}



/* Location:           C:\Users\Joker\Desktop\classes_dex2jar.jar

 * Qualified Name:     com.sz.ydgy.utils.XMLDOMParser

 * JD-Core Version:    0.7.0.1

 */